A fluid pressure device such as a fluid pressure cylinder or an electromagnetic valve assumes a structure that includes a detection switch used to detect the operating position of a piston, a valve member or the like, mounted in a switch mounting groove formed at a housing, so as to detect via the detection switch the magnetic field of a magnet installed in the piston, the valve member or the like.
Japanese Laid Open Patent Publication No. H10-196610 discloses a mechanism that may be adopted when mounting the detection switch at the housing of a fluid pressure cylinder. As shown in FIGS. 7 through 9, the switch mounting mechanism includes switch mounting grooves 2 formed at the housing 1, detection switches 3 assuming the shape of a rod, retainer screws 4 mounted at the detection switches 3 so as to advance/retreat freely and synthetic resin switch holders 5 each used to lock a detection switch 3 at a detection position within the corresponding switch mounting groove 2.
Each switch holder 5 in this switch mounting mechanism is pressed into the switch mounting groove 2 as the switch holder undergoes the process of elastic deformation through a groove opening 2a and is made to slide to a point close to the detection position. Then, the detection switch 3 is inserted in the switch mounting groove 2 at a position set apart from the switch holder 5 and the detection switch is made to slide to fit inside the switch holder 5. Next, the switch holder 5 and the detection switch 3 together are made to slide to the detection position. The retainer screw 4 is subsequently tightened until the front end of the retainer screw 4 is pressed in contact with the bottom of the switch mounting groove 2, thereby lifting up the detection switch 3. The switch holder 5 is pressed and held against groove walls 2b of the switch mounting groove 2 via the detection switch 3 in the lifted state and, as a result, the detection switch 3 is locked in place.